/*
 * Editor3DView.java
 */

package editor3d;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.StringReader;
import java.util.ArrayList;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 * The application's main frame.
 */
public class Editor3DView extends FrameView {
    private String vs_entrada, vsNombreArch;
    boolean blEjecutar=false;
    Integer ptr=0, ptrmemo=0, ptrPila=0;
    String ptr_val;
    ArrayList pila = new ArrayList();
    ArrayList heap = new ArrayList();
    ArrayList pilaop = new ArrayList();
    private ArrayList lstInstrucciones;
    public Editor3DView(SingleFrameApplication app) {
        super(app);

        initComponents();

        
        txtErrores.setText("");
        pnlDatos.setSelectedIndex(1);
        pnlEjecucion.setSelectedIndex(0);
        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String)(evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer)(evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = Editor3DApp.getApplication().getMainFrame();
            aboutBox = new Editor3DAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        Editor3DApp.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        pnlDatos = new javax.swing.JTabbedPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtEntrada = new javax.swing.JTextArea();
        jScrollPane2 = new javax.swing.JScrollPane();
        txt3D = new javax.swing.JTextArea();
        jScrollPane3 = new javax.swing.JScrollPane();
        txtOptimizado = new javax.swing.JTextArea();
        jScrollPane4 = new javax.swing.JScrollPane();
        txtAssembler = new javax.swing.JTextArea();
        jToolBar1 = new javax.swing.JToolBar();
        cmdGenerar3D = new javax.swing.JButton();
        cmdOptimizar = new javax.swing.JButton();
        cmdAsm = new javax.swing.JButton();
        cmdEjecutar = new javax.swing.JButton();
        cmdPasos = new javax.swing.JButton();
        pnlEjecucion = new javax.swing.JTabbedPane();
        jScrollPane5 = new javax.swing.JScrollPane();
        txtErrores = new javax.swing.JTextArea();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane6 = new javax.swing.JScrollPane();
        tblVar = new javax.swing.JTable();
        jLabel5 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane9 = new javax.swing.JScrollPane();
        tblHeap = new javax.swing.JTable();
        jLabel3 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane8 = new javax.swing.JScrollPane();
        tblPila = new javax.swing.JTable();
        jLabel4 = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jScrollPane11 = new javax.swing.JScrollPane();
        txtConsola = new javax.swing.JTextArea();
        jPanel6 = new javax.swing.JPanel();
        jScrollPane10 = new javax.swing.JScrollPane();
        tblPilaOp = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        mnuAbrirEnt = new javax.swing.JMenuItem();
        mnuAbrir3D = new javax.swing.JMenuItem();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        lblStatus = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        mainPanel.setName("mainPanel"); // NOI18N

        pnlDatos.setName("pnlDatos"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        txtEntrada.setColumns(20);
        txtEntrada.setRows(5);
        txtEntrada.setName("txtEntrada"); // NOI18N
        txtEntrada.addInputMethodListener(new java.awt.event.InputMethodListener() {
            public void caretPositionChanged(java.awt.event.InputMethodEvent evt) {
                txtEntradaCaretPositionChanged(evt);
            }
            public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
            }
        });
        txtEntrada.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtEntradaKeyTyped(evt);
            }
        });
        jScrollPane1.setViewportView(txtEntrada);

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(editor3d.Editor3DApp.class).getContext().getResourceMap(Editor3DView.class);
        pnlDatos.addTab(resourceMap.getString("jScrollPane1.TabConstraints.tabTitle"), jScrollPane1); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        txt3D.setColumns(20);
        txt3D.setRows(5);
        txt3D.setName("txt3D"); // NOI18N
        jScrollPane2.setViewportView(txt3D);

        pnlDatos.addTab(resourceMap.getString("jScrollPane2.TabConstraints.tabTitle"), jScrollPane2); // NOI18N

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        txtOptimizado.setColumns(20);
        txtOptimizado.setEditable(false);
        txtOptimizado.setRows(5);
        txtOptimizado.setName("txtOptimizado"); // NOI18N
        jScrollPane3.setViewportView(txtOptimizado);

        pnlDatos.addTab(resourceMap.getString("jScrollPane3.TabConstraints.tabTitle"), jScrollPane3); // NOI18N

        jScrollPane4.setName("jScrollPane4"); // NOI18N

        txtAssembler.setColumns(20);
        txtAssembler.setEditable(false);
        txtAssembler.setRows(5);
        txtAssembler.setName("txtAssembler"); // NOI18N
        jScrollPane4.setViewportView(txtAssembler);

        pnlDatos.addTab(resourceMap.getString("jScrollPane4.TabConstraints.tabTitle"), jScrollPane4); // NOI18N

        jToolBar1.setRollover(true);
        jToolBar1.setName("jToolBar1"); // NOI18N

        cmdGenerar3D.setIcon(resourceMap.getIcon("cmdGenerar3D.icon")); // NOI18N
        cmdGenerar3D.setText(resourceMap.getString("cmdGenerar3D.text")); // NOI18N
        cmdGenerar3D.setToolTipText(resourceMap.getString("cmdGenerar3D.toolTipText")); // NOI18N
        cmdGenerar3D.setName("cmdGenerar3D"); // NOI18N
        cmdGenerar3D.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                cmdGenerar3DMousePressed(evt);
            }
        });
        jToolBar1.add(cmdGenerar3D);

        cmdOptimizar.setIcon(resourceMap.getIcon("cmdOptimizar.icon")); // NOI18N
        cmdOptimizar.setText(resourceMap.getString("cmdOptimizar.text")); // NOI18N
        cmdOptimizar.setToolTipText(resourceMap.getString("cmdOptimizar.toolTipText")); // NOI18N
        cmdOptimizar.setName("cmdOptimizar"); // NOI18N
        cmdOptimizar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                cmdOptimizarMousePressed(evt);
            }
        });
        jToolBar1.add(cmdOptimizar);

        cmdAsm.setIcon(resourceMap.getIcon("cmdAsm.icon")); // NOI18N
        cmdAsm.setText(resourceMap.getString("cmdAsm.text")); // NOI18N
        cmdAsm.setToolTipText(resourceMap.getString("cmdAsm.toolTipText")); // NOI18N
        cmdAsm.setFocusable(false);
        cmdAsm.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        cmdAsm.setName("cmdAsm"); // NOI18N
        cmdAsm.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        cmdAsm.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                cmdAsmMousePressed(evt);
            }
        });
        jToolBar1.add(cmdAsm);

        cmdEjecutar.setIcon(resourceMap.getIcon("cmdEjecutar.icon")); // NOI18N
        cmdEjecutar.setText(resourceMap.getString("cmdEjecutar.text")); // NOI18N
        cmdEjecutar.setToolTipText(resourceMap.getString("cmdEjecutar.toolTipText")); // NOI18N
        cmdEjecutar.setName("cmdEjecutar"); // NOI18N
        cmdEjecutar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                cmdEjecutarMousePressed(evt);
            }
        });
        jToolBar1.add(cmdEjecutar);

        cmdPasos.setIcon(resourceMap.getIcon("cmdPasos.icon")); // NOI18N
        cmdPasos.setText(resourceMap.getString("cmdPasos.text")); // NOI18N
        cmdPasos.setToolTipText(resourceMap.getString("cmdPasos.toolTipText")); // NOI18N
        cmdPasos.setName("cmdPasos"); // NOI18N
        cmdPasos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                cmdPasosMousePressed(evt);
            }
        });
        jToolBar1.add(cmdPasos);

        pnlEjecucion.setName("pnlEjecucion"); // NOI18N

        jScrollPane5.setName("jScrollPane5"); // NOI18N

        txtErrores.setColumns(20);
        txtErrores.setEditable(false);
        txtErrores.setRows(5);
        txtErrores.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("txtErrores.border.title"))); // NOI18N
        txtErrores.setName("txtErrores"); // NOI18N
        jScrollPane5.setViewportView(txtErrores);

        pnlEjecucion.addTab(resourceMap.getString("jScrollPane5.TabConstraints.tabTitle"), jScrollPane5); // NOI18N

        jPanel1.setName("jPanel1"); // NOI18N

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel2.setName("jPanel2"); // NOI18N

        jScrollPane6.setName("jScrollPane6"); // NOI18N

        tblVar.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Tipo", "Nombre", "Valor"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblVar.setName("tblVar"); // NOI18N
        jScrollPane6.setViewportView(tblVar);
        tblVar.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("tblVar.columnModel.title0")); // NOI18N
        tblVar.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("tblVar.columnModel.title1")); // NOI18N
        tblVar.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("tblVar.columnModel.title2")); // NOI18N

        jLabel5.setFont(resourceMap.getFont("jLabel5.font")); // NOI18N
        jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 226, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                .addGap(54, 54, 54))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addComponent(jLabel5)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel5.setName("jPanel5"); // NOI18N

        jScrollPane9.setName("jScrollPane9"); // NOI18N

        tblHeap.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Dirección", "Contenido"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblHeap.setName("tblHeap"); // NOI18N
        jScrollPane9.setViewportView(tblHeap);
        tblHeap.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("tblVar.columnModel.title0")); // NOI18N
        tblHeap.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("tblVar.columnModel.title1")); // NOI18N

        jLabel3.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane9, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane9, javax.swing.GroupLayout.DEFAULT_SIZE, 203, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel4.setName("jPanel4"); // NOI18N

        jScrollPane8.setName("jScrollPane8"); // NOI18N

        tblPila.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Dirección", "Contenido"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblPila.setName("tblPila"); // NOI18N
        jScrollPane8.setViewportView(tblPila);
        tblPila.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("tblVar.columnModel.title0")); // NOI18N
        tblPila.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("tblVar.columnModel.title1")); // NOI18N

        jLabel4.setFont(resourceMap.getFont("jLabel4.font")); // NOI18N
        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4)
                .addGap(13, 13, 13)
                .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel7.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel7.setName("jPanel7"); // NOI18N

        jLabel6.setFont(resourceMap.getFont("jLabel6.font")); // NOI18N
        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jScrollPane11.setName("jScrollPane11"); // NOI18N

        txtConsola.setBackground(resourceMap.getColor("txtConsola.background")); // NOI18N
        txtConsola.setColumns(20);
        txtConsola.setEditable(false);
        txtConsola.setFont(resourceMap.getFont("txtConsola.font")); // NOI18N
        txtConsola.setForeground(resourceMap.getColor("txtConsola.foreground")); // NOI18N
        txtConsola.setRows(5);
        txtConsola.setName("txtConsola"); // NOI18N
        jScrollPane11.setViewportView(txtConsola);

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane11, javax.swing.GroupLayout.DEFAULT_SIZE, 340, Short.MAX_VALUE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 340, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane11, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel6.setName("jPanel6"); // NOI18N

        jScrollPane10.setName("jScrollPane10"); // NOI18N

        tblPilaOp.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Dirección", "Contenido"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblPilaOp.setName("tblPilaOp"); // NOI18N
        jScrollPane10.setViewportView(tblPilaOp);
        tblPilaOp.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("tblVar.columnModel.title0")); // NOI18N
        tblPilaOp.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("tblVar.columnModel.title1")); // NOI18N

        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                    .addComponent(jScrollPane10, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane10, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(55, 55, 55)
                        .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        pnlEjecucion.addTab(resourceMap.getString("jPanel1.TabConstraints.tabTitle"), jPanel1); // NOI18N

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 882, Short.MAX_VALUE)
                        .addGap(350, 350, 350))
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(pnlDatos, javax.swing.GroupLayout.PREFERRED_SIZE, 543, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(pnlEjecucion, javax.swing.GroupLayout.PREFERRED_SIZE, 659, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlDatos, javax.swing.GroupLayout.DEFAULT_SIZE, 519, Short.MAX_VALUE)
                    .addComponent(pnlEjecucion, javax.swing.GroupLayout.DEFAULT_SIZE, 519, Short.MAX_VALUE))
                .addContainerGap())
        );

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N
        fileMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fileMenuActionPerformed(evt);
            }
        });

        mnuAbrirEnt.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK));
        mnuAbrirEnt.setText(resourceMap.getString("mnuAbrirEnt.text")); // NOI18N
        mnuAbrirEnt.setName("mnuAbrirEnt"); // NOI18N
        mnuAbrirEnt.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                mnuAbrirEntMousePressed(evt);
            }
        });
        fileMenu.add(mnuAbrirEnt);

        mnuAbrir3D.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_3, java.awt.event.InputEvent.CTRL_MASK));
        mnuAbrir3D.setText(resourceMap.getString("mnuAbrir3D.text")); // NOI18N
        mnuAbrir3D.setName("mnuAbrir3D"); // NOI18N
        mnuAbrir3D.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                mnuAbrir3DMousePressed(evt);
            }
        });
        fileMenu.add(mnuAbrir3D);

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(editor3d.Editor3DApp.class).getContext().getActionMap(Editor3DView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        lblStatus.setText(resourceMap.getString("lblStatus.text")); // NOI18N
        lblStatus.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        lblStatus.setName("lblStatus"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 1232, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(statusMessageLabel)
                    .addComponent(lblStatus, javax.swing.GroupLayout.DEFAULT_SIZE, 1044, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblStatus, javax.swing.GroupLayout.DEFAULT_SIZE, 19, Short.MAX_VALUE)
                    .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(progressBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(statusMessageLabel)
                            .addComponent(statusAnimationLabel))))
                .addGap(11, 11, 11))
        );

        jButton1.setIcon(resourceMap.getIcon("jButton1.icon")); // NOI18N
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setToolTipText(resourceMap.getString("jButton1.toolTipText")); // NOI18N
        jButton1.setFocusable(false);
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton1.setName("jButton1"); // NOI18N
        jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

private void fileMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileMenuActionPerformed
   // if(!this.AbrirArchivo()) txtEntrada.setText("");
}//GEN-LAST:event_fileMenuActionPerformed

private void mnuAbrirEntMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mnuAbrirEntMousePressed
    pnlDatos.setSelectedIndex(0);
    if(!this.AbrirArchivo(1)) txtEntrada.setText("");
}//GEN-LAST:event_mnuAbrirEntMousePressed

private void mnuAbrir3DMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mnuAbrir3DMousePressed
    pnlDatos.setSelectedIndex(1);
    if(!this.AbrirArchivo(2)) txtEntrada.setText("");
}//GEN-LAST:event_mnuAbrir3DMousePressed

private void cmdGenerar3DMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cmdGenerar3DMousePressed
    if(txtEntrada.getText().compareToIgnoreCase("")!=0)
        this.compilar3D();
}//GEN-LAST:event_cmdGenerar3DMousePressed

private void cmdOptimizarMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cmdOptimizarMousePressed
    if(txt3D.getText().compareToIgnoreCase("")!=0)
        this.Optimizar();
}//GEN-LAST:event_cmdOptimizarMousePressed

private void cmdAsmMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cmdAsmMousePressed
    if(txtOptimizado.getText().compareToIgnoreCase("")!=0)
        this.compilarASM();
}//GEN-LAST:event_cmdAsmMousePressed

private void cmdEjecutarMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cmdEjecutarMousePressed
    if(blEjecutar)
        this.Ejecutar();
}//GEN-LAST:event_cmdEjecutarMousePressed

private void cmdPasosMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cmdPasosMousePressed
    if(blEjecutar)
        this.Ejecutar();
}//GEN-LAST:event_cmdPasosMousePressed

private void txtEntradaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtEntradaKeyTyped

}//GEN-LAST:event_txtEntradaKeyTyped

private void txtEntradaCaretPositionChanged(java.awt.event.InputMethodEvent evt) {//GEN-FIRST:event_txtEntradaCaretPositionChanged

}//GEN-LAST:event_txtEntradaCaretPositionChanged

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cmdAsm;
    private javax.swing.JButton cmdEjecutar;
    private javax.swing.JButton cmdGenerar3D;
    private javax.swing.JButton cmdOptimizar;
    private javax.swing.JButton cmdPasos;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane11;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JLabel lblStatus;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem mnuAbrir3D;
    private javax.swing.JMenuItem mnuAbrirEnt;
    private javax.swing.JTabbedPane pnlDatos;
    private javax.swing.JTabbedPane pnlEjecucion;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JTable tblHeap;
    private javax.swing.JTable tblPila;
    private javax.swing.JTable tblPilaOp;
    private javax.swing.JTable tblVar;
    private javax.swing.JTextArea txt3D;
    private javax.swing.JTextArea txtAssembler;
    private javax.swing.JTextArea txtConsola;
    private javax.swing.JTextArea txtEntrada;
    private javax.swing.JTextArea txtErrores;
    private javax.swing.JTextArea txtOptimizado;
    // End of variables declaration//GEN-END:variables

    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;

    private JDialog aboutBox;

        // Obtiene el nombre de un archivo del Path
    private String getNombreArch(String psPath)
    {
        String aux = new String();
        aux = psPath;
        
        int pos = 0;
        
        pos = aux.indexOf("/");
        
        while(pos!=-1)
        {
            aux = aux.substring(pos+1);
            pos = aux.indexOf("/");
        }
        
        return aux;
    }
    
    protected boolean AbrirArchivo(int viOpcion)
    {   
        boolean primera = true;
        boolean retornar = false;
        // Abre un cuadro de dialogo para abrir archivos
        JFileChooser jfcArchivo = new JFileChooser();
        //mostrando el Dialgo
        int viAccion  = jfcArchivo.showOpenDialog(this.txtEntrada);
        String vs_path;
        //si presionC3 Abrir
        if (viAccion==JFileChooser.APPROVE_OPTION)
        {
            //retorna al archivo que se hizo clikc
            File vfAbierto = jfcArchivo.getSelectedFile();
            if (vfAbierto!=null)
            {
                vs_path = vfAbierto.getPath();
                String vsNombre = vfAbierto.getName();
                //Leer el archivo de entrada
                try{
                    FileReader vfrLectorArchivo = new FileReader(vs_path);
                    BufferedReader vbfEntrada = new BufferedReader(vfrLectorArchivo);
                    
                    String vsLinea = null; 
                    this.vs_entrada = "";
                    // Obtenemos Linea por Linea del Archivo
                    while ((vsLinea = vbfEntrada.readLine())!=null)
                    {   if (primera==true)
                        {   
                            this.vs_entrada = this.vs_entrada + vsLinea;
                            primera = false;
                        }
                        else
                            this.vs_entrada = this.vs_entrada + "\n" + vsLinea;
                        vsLinea =""; 
                    }
                    vbfEntrada.close();
                    vfrLectorArchivo.close();
                    vsNombreArch = getNombreArch(vs_path);
                    if(viOpcion ==1)
                        txtEntrada.setText(vs_entrada);
                    else
                        txt3D.setText(vs_entrada);
                    retornar = true;
                    //this.pCompilar();
                }
                catch(Exception e)
                {
                     JOptionPane msgError = new JOptionPane();
                     msgError.showConfirmDialog(this.txtEntrada, "Ocurrio un error al abrir el archivo de entrada.\n" + e.getMessage(), "Espere", JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE, null);
                }
            }
        }
        else
            retornar = false;
        return retornar;
    }   
    
    public void compilar3D(){
        txt3D.setText("");
        txtErrores.setText("");
        String errores="";
        lexicoTS veLexico = null;
        parserTS sintacTS = null;
        lexico veEscaner = null;
        parser vpParser = null;
        blEjecutar=false;
        try {
            TablaClase  tabla = new TablaClase();
            lblStatus.setText("Inicia verificación de errores");
            veLexico = new lexicoTS(new StringReader(txtEntrada.getText()));
            sintacTS = new parserTS(veLexico);
            sintacTS.parse();
            errores = veLexico.getErrores();
            errores = errores + sintacTS.getErrores();
            //txtErrores.setText(errores);
            tabla = sintacTS.getTabla();
            lblStatus.setText("Inicia verificación semántica y generación de código de 3D");
            veEscaner = new lexico (new StringReader(txtEntrada.getText()));
            vpParser = new parser(veEscaner, tabla);
            vpParser.parse();
            if(errores.isEmpty()){
                 pnlDatos.setSelectedIndex(1);
                 lblStatus.setText("No se detectaron errores, el código 3D se generó adecuadamente");
                 txt3D.setText(vpParser.getCodigo3D());
            }else{
                txtErrores.setText(errores);
            }
        } catch (Exception ex) {
            errores = veLexico.getErrores();
            errores = errores + sintacTS.getErrores();
            lblStatus.setText("Se detectaron errores, no se completo la operación");
            //txtErrores.setText(errores);
            Logger.getLogger(Editor3DView.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }
    
    private void Optimizar(){
        try{             
            String cad=txt3D.getText();
            String cad2="", traducir="";
            int pos=0;
            while(!cad.isEmpty()){
                    cad2=cad.substring(0,cad.indexOf("\n"));
                    cad=cad.substring(cad.indexOf("\n")+1, cad.length());
                    if(!cad2.contains("include")){
                        if(cad2.contains("main"))
                            cad2=cad2.replace("int", "void");
                        traducir+="\n"+cad2;
                    }
            }
            lexopt LexOpt = new lexopt(new StringReader(traducir));
            parserOPT sintactOPT = new parserOPT(LexOpt);
            sintactOPT.parse();
            ArrayList lstCodigo = new ArrayList();
            lstCodigo = sintactOPT.getCodOpt();
            lstCodigo = this.SimplificacionAlgebraica(lstCodigo);
            lstCodigo = this.GotosAdyacentes(lstCodigo);
            //lstCodigo = this.FlujoEjecucion(lstCodigo);
            traducir = this.CodigoOptimizado(lstCodigo);
            txtOptimizado.setText(traducir);
            pnlDatos.setSelectedIndex(2);
            blEjecutar=false;
        } catch (Exception ex) {
                Logger.getLogger(Editor3DView.class.getName()).log(Level.SEVERE, null, ex);
            }
      
    }
    
    private void compilarASM(){
        try {
            String cad=txtOptimizado.getText();
            String cad2="", traducir="";
            int pos=0;
            while(!cad.isEmpty()){
                    cad2=cad.substring(0,cad.indexOf("\n"));
                    cad=cad.substring(cad.indexOf("\n")+1, cad.length());
                    if(!cad2.contains("include")){
                        if(cad2.contains("main"))
                            cad2=cad2.replace("int", "void");
                        traducir+="\n"+cad2;
                    }
            }
            lexasm LexAsm = new lexasm(new StringReader(traducir));
            parserASM sintactASM = new parserASM(LexAsm);
            sintactASM.parse();   
            lstInstrucciones = sintactASM.getIntrucciones();
            txtAssembler.setText("");
            txtAssembler.setText(sintactASM.getCodigo());
            pnlDatos.setSelectedIndex(3);
            blEjecutar=true;
        } catch (Exception ex) {
            blEjecutar=false;
            Logger.getLogger(Editor3DView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    private void Ejecutar(){
        pnlEjecucion.setSelectedIndex(1);
        this.ActualizaVariables();
        cInterprete inter = new cInterprete();
        for(int i=0; i<lstInstrucciones.size();i++){
            inter = (cInterprete)lstInstrucciones.get(i);
            if(inter.vsNombre.compareTo("main")==0){
                    this.Interprete(inter);
                }
            }
    }
    
    private void ActualizaVariables(){
        cInterprete inter = new cInterprete();
        for(int i=0; i<lstInstrucciones.size();i++){
            inter = (cInterprete)lstInstrucciones.get(i);
            if(inter.vsNombre.compareTo("_VARS_")==0){
                cCodigo cod = new cCodigo();
                for(int j=0; j<inter.voCodigo.size(); j++){
                        cod = (cCodigo)inter.voCodigo.get(j);
                        tblVar.setValueAt(cod.vsDir1,j, 0);
                        tblVar.setValueAt(cod.vsDir2,j, 1);
                        tblVar.setValueAt(cod.vsDir3,j, 2);
                    }
                }
            }
      }
    
    private void Interprete(cInterprete Inter){
            cCodigo cod = new cCodigo(), sigcod = new cCodigo();
            cInterprete sig = new cInterprete(); 
            String val1, val2;
            String indice; int index=0;
            double valor1, valor2;
            for(int i=0; i<Inter.voCodigo.size();i++){
            try {
                cod = (cCodigo)Inter.voCodigo.get(i);
                switch(cod.viTipo){
                    case 0:    // VARS 
                        break;
                    case 1:    // PROCS 
                        break;
                    case 2:    // TIPO_IF 
                        val1="";
                        if(cod.vsDir1.compareTo("pilaop")==0) val1=(String)pilaop.get(ptrPila);
                        else {
                            if(Inter.esVariable(cod.vsDir1)){
                               val2=Inter.obtieneValor(cod.vsDir2);
                            }else if(cod.vsDir1.contains("pila") || cod.vsDir1.contains("heap") ){
                                indice =  cod.vsDir1.substring(cod.vsDir1.indexOf("."));
                                if(Inter.esVariable(indice)) {
                                    indice = Inter.obtieneValor(indice);
                                    index = Integer.parseInt(indice);
                                    if(cod.vsDir1.contains("pila")) val1 = (String)pila.get(index);
                                    if(cod.vsDir1.contains("heap")) val1 = (String)pila.get(index);
                                }else{
                                    index = Integer.parseInt(indice);
                                    if(cod.vsDir1.contains("pila")) val1 = (String)pila.get(index);
                                    if(cod.vsDir1.contains("heap")) val1 = (String)pila.get(index);
                                }
                            }  else {
                                    if(cod.vsDir1.contains("ptr")) val1 = ptr.toString();
                                    if(cod.vsDir1.contains("memo")) val1 = ptrmemo.toString();
                                    if(cod.vsDir1.contains("ptr_val")) val1 = ptr_val;
                                    if(val1.compareTo("")==0) val1 = cod.vsDir1;
                                }
                        }
                        val2="";
                        if(cod.vsDir2.compareTo("pilaop")==0) val2=(String)pilaop.get(ptrPila);
                        else {
                            if(Inter.esVariable(cod.vsDir2)){
                                val2=Inter.obtieneValor(cod.vsDir2);
                            }else if(cod.vsDir2.contains("pila.") || cod.vsDir2.contains("heap.") ){
                                indice =  cod.vsDir2.substring(cod.vsDir2.indexOf("."));
                                if(Inter.esVariable(indice)) {
                                    indice = Inter.obtieneValor(indice);
                                    index = Integer.parseInt(indice);
                                    if(cod.vsDir2.contains("pila.")) val2 = (String)pila.get(index);
                                    if(cod.vsDir2.contains("heap.")) val2 = (String)pila.get(index);
                                }else{
                                    index = Integer.parseInt(indice);
                                    if(cod.vsDir1.contains("pila.")) val2 = (String)pila.get(index);
                                    if(cod.vsDir1.contains("heap.")) val2 = (String)pila.get(index);
                                }
                            }else {
                                    if(cod.vsDir2.contains("ptr")) val2 = ptr.toString();
                                    if(cod.vsDir2.contains("memo")) val2 = ptrmemo.toString();
                                    if(cod.vsDir2.contains("ptr_val")) val2 = ptr_val;
                                    if(val1.compareTo("")==0) val2 = cod.vsDir2;
                            }
                        }
                        if(evaluarExpresion(val1, val2, cod.vsOp)){
                            while(!sigcod.vsDir1.equals(cod.vsDir1)||sigcod.viTipo!=sigcod.TIPO_ET){
                                i++;
                                sigcod=(cCodigo)Inter.voCodigo.get(i);
                            }
                            i--;
                        }
                        break;
                    case 3:    // TIPO_GOTO 
                        while(!sigcod.vsDir1.equals(cod.vsDir1)||sigcod.viTipo!=sigcod.TIPO_ET){
                            i++;
                            sigcod=(cCodigo)Inter.voCodigo.get(i);
                        }
                        i--;
                        break;
                    case 4:    // TIPO_ET 
                        break;
                    case 5:    // TIPO_PRINT 
                        txtConsola.append(ptr_val);
                        break;
                    case 6:    // TIPO_CALL
                        for(int j=0; j<lstInstrucciones.size(); j++){
                            sig = (cInterprete)lstInstrucciones.get(j);
                            if(sig.vsNombre.equals(cod.vsDir1)){
                                this.Interprete(sig);
                            }
                        }
                        break;
                    case 7:    // TIPO_ASIG 
                        val1="";
                        if(cod.vsDir1.compareTo("pilaop")==0) val1="pilaop";
                        else {
                            if(Inter.esVariable(cod.vsDir1)){
                                val1=cod.vsDir1;
                            }else if(cod.vsDir1.contains("pila.") || cod.vsDir1.contains("heap.") ){
                                indice =  cod.vsDir1.substring(cod.vsDir1.indexOf("."));
                                if(Inter.esVariable(indice)) {
                                    indice = Inter.obtieneValor(indice);
                                    index = Integer.parseInt(indice);
                                }else{
                                    index = Integer.parseInt(indice);
                                }
                            }  else {
                                    if(cod.vsDir1.contains("ptr")) val1 = ptr.toString();
                                    if(cod.vsDir1.contains("memo")) val1 = ptrmemo.toString();
                                    if(cod.vsDir1.contains("ptr_val")) val1 = ptr_val;
                                    if(val1.compareTo("")==0) val1 = cod.vsDir1;
                                }
                        }
                        val2="";
                        if(cod.vsDir2.compareTo("pilaop")==0) val2="pilaop";
                        else {
                            if(Inter.esVariable(cod.vsDir2)){
                                val2=Inter.obtieneValor(cod.vsDir2);
                            }else if(cod.vsDir2.contains("pila.") || cod.vsDir2.contains("heap.") ){
                                indice =  cod.vsDir2.substring(cod.vsDir2.indexOf("."));
                                if(Inter.esVariable(indice)) {
                                    indice = Inter.obtieneValor(indice);
                                    index = Integer.parseInt(indice);
                                    if(cod.vsDir2.contains("pila.")) val2 = (String)pila.get(index);
                                    if(cod.vsDir2.contains("heap.")) val2 = (String)pila.get(index);
                                }else{
                                    index = Integer.parseInt(indice);
                                    if(cod.vsDir1.contains("pila.")) val2 = (String)pila.get(index);
                                    if(cod.vsDir1.contains("heap.")) val2 = (String)pila.get(index);
                                }
                            }else {
                                    if(cod.vsDir2.contains("ptr")) val2 = ptr.toString();
                                    if(cod.vsDir2.contains("memo")) val2 = ptrmemo.toString();
                                    if(cod.vsDir2.contains("ptr_val")) val2 = ptr_val;
                                    if(val1.compareTo("")==0) val2 = cod.vsDir2;
                            }
                        }
                        if(val1.equals("pilaop")) {
                            if(pilaop.size()>0 && ptrPila<pilaop.size()){
                            ptrPila++;
                            pilaop.add(ptrPila, val2);
                            ActualizaPilaOp(val2);
                            }else{
                                pilaop.add( val2);
                                ptrPila = pilaop.size();
                                ActualizaPilaOp(val2);
                            }
                        }
                        
                        if(val1.compareTo("pila.")==0) {
                            pila.set(index,val2);
                            ActualizaPila(index, val2);
                        }
                        
                        if(val1.compareTo("heap.")==0) {
                            heap.set(index,val2);
                            ActualizaHeap(index, val2);
                        }
                        if(Inter.esVariable(val1)){
                            Inter.actualizaValor(val1, val2);
                            this.ActualizaVariables();
                        }
                        break;
                    case 8:    // TIPO_DEC 
                        break;
                    case 9:    // TIPO_OTRO 
                        break;
                    case 10:    // OP_SUMA
                        valor1 = (Integer)pilaop.get(ptrPila);
                        valor2 = (Integer)pilaop.get(ptrPila-1);
                        valor1=valor1+valor2;
                        ActualizaPilaOp("");
                        ptrPila--;
                        val1 = valor1+"";
                        ActualizaPilaOp(val1);
                        pilaop.set(ptrPila, val1);
                        break;
                    case 11:    // OP_RESTA 
                        valor1 = (Integer)pilaop.get(ptrPila);
                        valor2 = (Integer)pilaop.get(ptrPila-1);
                        valor1=valor1-valor2;
                        ActualizaPilaOp("");
                        ptrPila--;
                        val1 = valor1+"";
                        ActualizaPilaOp(val1);
                        pilaop.set(ptrPila, val1);
                        break;
                    case 12:    // OP_MUL 
                        valor1 = (Integer)pilaop.get(ptrPila);
                        valor2 = (Integer)pilaop.get(ptrPila-1);
                        valor1=valor1*valor2;
                        ActualizaPilaOp("");
                        ptrPila--;
                        val1 = valor1+"";
                        ActualizaPilaOp(val1);
                        pilaop.set(ptrPila, val1);
                        break;
                    case 13:    // OP_DIV 
                        valor1 = (Integer)pilaop.get(ptrPila);
                        valor2 = (Integer)pilaop.get(ptrPila-1);
                        valor1=valor1/valor2;
                        ActualizaPilaOp("");
                        ptrPila--;
                        val1 = valor1+"";
                        ActualizaPilaOp(val1);
                        pilaop.set(ptrPila, val1);
                        break;
                    case 14:    // OP_MOD 
                        valor1 = (Integer)pilaop.get(ptrPila);
                        valor2 = (Integer)pilaop.get(ptrPila-1);
                        valor1=valor1%valor2;
                        ActualizaPilaOp("");
                        ptrPila--;
                        val1 = valor1+"";
                        ActualizaPilaOp(val1);
                        pilaop.set(ptrPila, val1);
                        break;
                    case 15:    // OP_CMP 
                        val1="";
                        valor1 = (Integer)pilaop.get(ptrPila);
                        valor2 = (Integer)pilaop.get(ptrPila-1);
                        ActualizaPilaOp("");
                        ptrPila--;
                        if(valor1==valor2) {val1="0";}
                        if(valor1!=valor2) {val1="99";}
                        if(valor1<valor2) {val1="-1";}
                        if(valor1<=valor2) {val1="-2";}
                        if(valor1>valor2) {val1="1";}
                        if(valor1>=valor2) {val1="2";}
                        ActualizaPilaOp(val1);
                        pilaop.set(ptrPila, val1);
                        break;
                }
                Thread.sleep(500);
            } catch (InterruptedException ex) {
                Logger.getLogger(Editor3DView.class.getName()).log(Level.SEVERE, null, ex);
            }
            }
      }

private boolean evaluarExpresion(String val1, String val2, String vsOp){
    double valor1, valor2;
    valor1=Integer.valueOf(val1);
    valor2=Integer.valueOf(val2);
    if(vsOp.equals("==")){
        if(valor1==valor2)
            return true;
    }
    if(vsOp.equals("!=")){
        if(valor1!=valor2)
            return true;
    }
    if(vsOp.equals(">")){
        if(valor1>valor2)
            return true;
    }
    if(vsOp.equals("<")){
        if(valor1<valor2)
            return true;
    }
    if(vsOp.equals(">=")){
        if(valor1>=valor2)
            return true;
    }
    if(vsOp.equals("<=")){
        if(valor1<=valor2)
            return true;
    }
    
    return false;
}
    
    private void ActualizaPilaOp(String Val){
         tblPilaOp.setValueAt(ptrPila.toString(),ptrPila, 0);
         tblPilaOp.setValueAt(Val,ptrPila, 1);
    }
    
   private void ActualizaPila(Integer index, String Val){
         tblPila.setValueAt(index.toString(),index, 0);
         tblPila.setValueAt(Val,index, 1);
    }
    
   private void ActualizaHeap(Integer index, String Val){
         tblHeap.setValueAt(index.toString(),index, 0);
         tblHeap.setValueAt(Val,index, 1);
    }
   
    private ArrayList SimplificacionAlgebraica(ArrayList lstCodigo){
        ArrayList lista = new ArrayList();
        try {
            cCodigo oCodigo = new cCodigo();
            int cont=0;
            for(int i=0; i<lstCodigo.size();i++){
                oCodigo = (cCodigo)lstCodigo.get(i);
                if(oCodigo.viTipo==oCodigo.TIPO_ASIG){
                    if(oCodigo.vsDir2.endsWith(" + 0")||oCodigo.vsDir2.endsWith("+0")) {
                        oCodigo.vsDir2 = oCodigo.vsDir2.substring(0,oCodigo.vsDir2.indexOf("+"));
                        cont++;
                    }
                    if(oCodigo.vsDir2.endsWith(" - 0")||oCodigo.vsDir2.endsWith("-0")){
                        oCodigo.vsDir2 = oCodigo.vsDir2.substring(0,oCodigo.vsDir2.indexOf("-"));
                        cont++;
                    }
                    if(oCodigo.vsDir2.endsWith(" * 1")||oCodigo.vsDir2.endsWith("*1")){
                        oCodigo.vsDir2 = oCodigo.vsDir2.substring(0,oCodigo.vsDir2.indexOf("*"));
                        cont++;
                    }
                    if(oCodigo.vsDir2.endsWith(" / 1")||oCodigo.vsDir2.endsWith("/1")){
                        oCodigo.vsDir2 = oCodigo.vsDir2.substring(0,oCodigo.vsDir2.indexOf("/"));
                        cont++;
                    }
                }
                lista.add(oCodigo);
                
            }
            lblStatus.setText("Se realizaron " + cont + " Simplificaciones Algebraicas");
            Thread.sleep(100);
            return lista;
        } catch (InterruptedException ex) {
            Logger.getLogger(Editor3DView.class.getName()).log(Level.SEVERE, null, ex);
        }
        return lstCodigo;
    }
    
    private ArrayList GotosAdyacentes(ArrayList lstCodigo){
        ArrayList lista = new ArrayList();
        try {
            int cont = 0;
            cCodigo actual = new cCodigo();
            cCodigo siguiente = new cCodigo();
            for(int i=0; i<lstCodigo.size()-1;i++){
                actual = (cCodigo)lstCodigo.get(i);
                if(actual.viTipo==actual.TIPO_GOTO){
                    siguiente = (cCodigo)lstCodigo.get(i+1);
                    if(siguiente.viTipo==siguiente.TIPO_ET){
                        if(actual.vsDir1.compareTo(siguiente.vsDir1)==0){
                            cont=cont+2;
                        }else {
                            lista.add(actual);
                        }
                    }
                }else{
                    lista.add(actual);
                }
            } 
            if(actual.vsDir1.compareTo(siguiente.vsDir1)!=0)
                lista.add((cCodigo)lstCodigo.get(lstCodigo.size()-1));
            lblStatus.setText("Se eliminaron " + cont + " Gotos con etiqueta adyacente");
            Thread.sleep(100);
            return lista;
        } catch (InterruptedException ex) {
            Logger.getLogger(Editor3DView.class.getName()).log(Level.SEVERE, null, ex);
        }
        return lstCodigo;
    }
    
    private String CodigoOptimizado(ArrayList lstCodigo){
        String codigo = "";
        cCodigo actual = new cCodigo();
        for(int i=0; i<lstCodigo.size(); i++){
            actual = (cCodigo)lstCodigo.get(i);
            if(actual.viTipo==actual.TIPO_DEC){
                if(!actual.vsDir3.isEmpty())//es un arreglo
                    codigo += actual.vsDir1 + " " + actual.vsDir2+ "[" + actual.vsDir3 + "]" + "; \n";
                else
                    codigo += actual.vsDir1 + " " + actual.vsDir2 + "; \n";
            }else if(actual.viTipo==actual.TIPO_ASIG){
                codigo += actual.vsDir1 + " = " + actual.vsDir2 + actual.vsOp + actual.vsDir3 + "; \n";
            }else if(actual.viTipo==actual.PROCS){
                if(actual.vsDir2.contains("main"))
                    codigo += actual.vsDir1 + " " + actual.vsDir2 + "";
                else
                    codigo += actual.vsDir1 + " " + actual.vsDir2 + "()";
            }else if(actual.viTipo==actual.TIPO_CALL){
                codigo += actual.vsDir1 + "(); \n";
            }else if(actual.viTipo==actual.TIPO_ET){
                codigo += actual.vsDir1 + ": \n";
            }else if(actual.viTipo==actual.TIPO_GOTO){
                codigo += "goto " + actual.vsDir1 + "; \n";
            }else if(actual.viTipo==actual.TIPO_PRINT){
                codigo += "printf (" + actual.vsDir1 + "," + actual.vsDir2 + "); \n";
            }else if(actual.viTipo==actual.TIPO_IF){
                codigo += "if (" + actual.vsDir1 +  actual.vsOp + actual.vsDir2 + ")" + " goto " + actual.vsDir3 + "; \n";
            }else if(actual.viTipo==actual.TIPO_OTRO){
                codigo += actual.vsDir1 + " \n";
            }
        }
        return codigo;
    }
    
    private ArrayList FlujoEjecucion(ArrayList lstCodigo){
        cCodigo actual = new cCodigo(), et_verdadera = new cCodigo();
        cCodigo siguiente = new cCodigo(), et_falsa = new cCodigo();
        boolean operacion=false, verdadera=false, falsa =false;
        String etV, etF;
        for(int i=0; i<lstCodigo.size()-1; i++){
            actual = (cCodigo)lstCodigo.get(i);
            if(actual.viTipo==actual.TIPO_IF){
                if(actual.vsDir1.compareTo(actual.vsDir2)==0){
                    if(actual.vsOp.compareTo("==")==0){ //borrar todo hasta encontrar la etiqueta de verdadero
                      etV=actual.vsDir3;
                      for(int j=i+1; j<lstCodigo.size();j++){
                          siguiente = (cCodigo)lstCodigo.get(j);
                          if(siguiente.viTipo==siguiente.TIPO_ET && siguiente.vsDir3.compareTo(etV)==0){ //verifico si es la etV
                              
                          }else{ //elimino la linea
                              lstCodigo.remove(j);
                              j--;
                          }
                      }
                    }
                }
            }
        }
        return lstCodigo;
    }
}
